package com.javaAPI.demo2;

public class Test {
    public static void main(String[] args) {


        //多态   父类引用指向子类对象
        Student student = new Student();
        student.setName("lili");
        student.setAge(20);
        //第一步，调用valueOf()方法
//        String s = String.valueOf(x);
//        if (getClass() == PrintStream.class) {
//            // need to apply String.valueOf again since first invocation
//            // might return null
//            writeln(String.valueOf(s));
//        } else {
//            synchronized (this) {
//                print(s);
//                newLine();
//            }
//        }
//      //第二步，判断是否为空，调用obj.toString()方法
//        return (obj == null) ? "null" : obj.toString();

//        //第三步，Integer.toHexString(hashCode())该对象的hashCode值
//        return getClass().getName() + "@" + Integer.toHexString(hashCode());

        System.out.println(student);
//        System.out.println(student.getClass().getName() + "@" + Integer.toHexString(student.hashCode()));
        System.out.println(student.toString());
        //父类引用指向子类对象
        Object parent = new Parent();
    }
}
